﻿@{
    ViewData["Title"] = "小程序用户列表 ";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">微信名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="nickName" autocomplete="off" class="layui-input" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>

@section js{
    <script>
        layui.use(['form', 'layer', 'table', 'element', 'common'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                apiUtil = layui.common;
            //layui button onclick必须这样写，不然会出现事件未定义；
            window.existAuth = function (btnName) {              
                apiUtil.checkAuth("appUser", btnName, event);
            };
            apiUtil.render({
                elem: '#currentTableId',
                url: 'appUser/getListPages',
                toolbar: '#toolbarDemo',
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                authorizeFields: true, // 字段权限开关
                overflow: { // 默认所有表格都超出
                    type: 'tips'
                    , hoverTime: 300 // 悬停时间，单位ms, 悬停 hoverTime 后才会显示，默认为 0
                    , color: 'black' // 字体颜色
                    , bgColor: 'white' // 背景色
                    , header: true, // 表头支持 overflow
                    total: true // 合计行支持 overflow
                },
                cols: [[
                    { type: "checkbox", width: 50 },
                    { field: 'id', width: 80, title: 'ID', sort: true },
                    { field: 'openId', width: 80, title: 'ID', sort: true },
                    { field: 'tenantName', title: '租户名称' },
                    {
                        field: 'nickName', title: '微信名称', templet: function (res) {
                            return '<a href="javascript:void(0)" lay-event="edit" class="text-color">' + res.nickName + '</a>';
                        }
                    },
                    {
                        field: 'avatarUrl', title: '头像', width: 80, templet: function (data) {
                            return '<img src="' + data.avatarUrl + '" style="width:40px;height:40px;" />';
                        }
                    },
                    { field: 'gender', title: '性别' },
                    { field: 'country', title: '国家' },
                    { field: 'province', title: '省份' },
                    { field: 'city', title: '城市' },
                    { field: 'createTime', title: '创建时间' },
                    { title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center" }
                ]],
                limit: 15,
                parseData: function (res) {
                    return apiUtil.parseDataFun(res);
                }
            });

            // 监听搜索操作
            form.on('submit(data-search-btn)', function (data) {
               // var result = JSON.stringify(data.field);
                //执行搜索重载
                table.reload('currentTableId', {
                    page: {
                        curr: 1
                    }
                    , where: {
                        key: data.field.nickName
                    }
                }, 'data');
                return false;
            });
        });
    </script>
}

